<?php
namespace Common\Controller;
use Think\Controller;
use Org\Util\Rbac;                                       

class CommonController extends BaseController {
    public function _initialize(){ 
		parent::_initialize();
		$LG_USER = session('LG_USER');
		if (empty($LG_USER)){
           $this->error('请重新登录', U('Home/Public/login')); 
        }
        $access = Rbac::AccessDecision(); 
        if(!$access){
            $this->error('你没有权限');
        }
		$this->assign('LG_USER',session('LG_USER')); 
    }

    public function lists($model, $map = [], $order = 'id desc')
    {
        if(is_string($model)){
            $model = M($model);
        }
        $Count = $model->where($map)->count();
        $Page = new \Think\Pager($Count,10);
        $show = $Page->showhtml();
        $list = $model->where($map)->limit($Page->firstRow.','.$Page->listRows)->order($order)->select();
        return [$list, $show];
    }
	
}